import request from '@/config/axios'

// 商品库存 VO
export interface ProductInventoryVO {
  id: number // 主键
  shopId: number // 店铺ID（关联shop表id）
  spuId: number // 商品ID
  skuId: number // 库存单元ID
  stock: number // 当前库存数量
  salesStock:number //实际销量
  supplyPrice:number  //供应商价格
}

// 商品库存 API
export const ProductInventoryApi = {
  // 查询商品库存分页
  getProductInventoryPage: async (params: any) => {
    return await request.get({ url: `/productShopInventory/page`, params })
  },

  // 查询商品库存详情
  getProductInventoryById: async (id: number) => {
    return await request.get({ url: `/productShopInventory/getById?id=` + id })
  },

  // 新增商品库存
  createProductInventory: async (data: ProductInventoryVO) => {
    return await request.post({ url: `/productShopInventory/create`, data })
  },

  // 修改商品库存
  updateProductInventory: async (data: ProductInventoryVO) => {
    return await request.post({ url: `/productShopInventory/update`, data })
  },

  // 修改商品库存状态
  updateProductInventoryStatus: async (id: number, status: number) => {
    const data = {
      id,
      status
    }
    return await request.post({ url: `/productShopInventory/updateStatus`, data: data })
  },

  // 删除商品库存
  deleteProductInventoryById: async (id: number) => {
    return await request.get({ url: `/productShopInventory/delete?id=` + id })
  },

  // 导出商品库存 Excel
  exportProductInventory: async (params) => {
    return await request.download({ url: `/productShopInventory/export-excel`, params })
  }
}